/**
 * @param {number} rowIndex
 * @return {number[]}
 */
var getRow = function(rowIndex) {
  let arr = [[1]];
  for(let i = 1; i < rowIndex + 1; i++) {
    let tempArr = [];
    for(let j = 0; j < i + 1; j++) {
      if(j == 0 || j == i) {
        tempArr[j] = 1;
      } else {
        tempArr[j] = arr[i - 1][j - 1] + arr[i - 1][j];
      }
    }
    arr.push(tempArr);
  }
  return arr[rowIndex];
};
let rowIndex = 3;
console.log(getRow(rowIndex));
rowIndex = 0;
console.log(getRow(rowIndex));
rowIndex = 1;
console.log(getRow(rowIndex));
